﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Simple.Services;
namespace Simple.WebApi.Controllers.System;

/// <summary>
/// 关键作业分析
/// </summary>
[Route("QHSEViolationKeyWork/[action]")]
[ApiController]
public class QHSEViolationKeyWorkController : ControllerBase
{
    private readonly ViolationKeyWorkAnalysisService _violationKeyWorkAnalysisService;

    public QHSEViolationKeyWorkController(ViolationKeyWorkAnalysisService violationKeyWorkAnalysisService)
    {
        _violationKeyWorkAnalysisService = violationKeyWorkAnalysisService;
    }
    /// <summary>
    /// 关键作业分析--关键作业
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_gjzy_analysis")]
    public async Task<AppResult> KeyWorkAnalysis([FromBody] ViolationKeyWorkInput input)
    {
        var res = await _violationKeyWorkAnalysisService.KeyWorkAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 关键作业分析--违章性质
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_gjzy_analysis")]
    public async Task<AppResult> ViolationTypeAnalysis([FromBody] ViolationKeyWorkInput input)
    {
        var res = await _violationKeyWorkAnalysisService.ViolationTypeAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 关键作业分析--年龄
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_gjzy_analysis")]
    public async Task<AppResult> AgeAnalysis([FromBody] ViolationKeyWorkInput input)
    {
        var res = await _violationKeyWorkAnalysisService.AgeAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 关键作业分析--工龄
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_gjzy_analysis")]
    public async Task<AppResult> WorkYearsAnalysis([FromBody] ViolationKeyWorkInput input)
    {
        var res = await _violationKeyWorkAnalysisService.WorkYearsAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 关键作业分析--人的不安全行为/管理缺陷
    /// </summary>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_gjzy_analysis")]
    public async Task<AppResult> UnsafeFactorsAnalysis([FromBody] ViolationKeyWorkInput input)
    {
        var res = await _violationKeyWorkAnalysisService.ViolationCategoryAnalysisAsync(input, "不安全因素");
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 关键作业分析--人的不安全行为
    /// </summary>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_gjzy_analysis")]
    public async Task<AppResult> UnsafeBehaviorAnalysis([FromBody] ViolationKeyWorkInput input)
    {
        var res = await _violationKeyWorkAnalysisService.ViolationCategoryAnalysisAsync(input, "人的不安全行为");
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 关键作业分析--管理缺陷
    /// </summary>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_gjzy_analysis")]
    public async Task<AppResult> ManagementDeficienciesAnalysis([FromBody] ViolationKeyWorkInput input)
    {
        var res = await _violationKeyWorkAnalysisService.ViolationCategoryAnalysisAsync(input, "管理缺陷");
        return AppResult.Status200OK(data: res);
    }
}

